#include "abstract_picture.h"
#include "../core/inspector.h"
#include <cmath>
using namespace Commands;
using namespace Commands::Core;

AbstractPicture::AbstractPicture()
: x_coord(0.0f)
, y_coord(0.0f)
, width(0.0f)
, height(0.0f)
, angle(0.0f)
, x_scale(1.0f)
, y_scale(1.0f)
, x_anchor(0.0f)
, y_anchor(0.0f)
, alpha(0)
, z_order(0)
, flip(NONE)
{}
//-----------------------------------------------------------------------------
AbstractPicture::AbstractPicture(const AbstractPicture&)
: x_coord(0.0f)
, y_coord(0.0f)
, width(0.0f)
, height(0.0f)
, angle(0.0f)
, x_scale(1.0f)
, y_scale(1.0f)
, x_anchor(0.0f)
, y_anchor(0.0f)
, alpha(0)
, z_order(0)
, flip(NONE)
{}
//-----------------------------------------------------------------------------
AbstractPicture& AbstractPicture::operator=(const AbstractPicture&)
{
    return *this;
}
//-----------------------------------------------------------------------------
AbstractPicture::~AbstractPicture()
{}
//-----------------------------------------------------------------------------
void AbstractPicture::Accept(const Inspector& inspector)
{
    const_cast<Inspector&>(inspector).Inspect(*this);
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetWidth(void) const
{
    return width;
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetHeight(void) const
{
    return height;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetX(const float x)
{
    x_coord = x;
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetX(void) const
{
    return x_coord;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetY(const float y)
{
    y_coord = y;
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetY(void) const
{
    return y_coord;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetXY(const float x, const float y)
{
    x_coord = x;
    y_coord = y;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetZOrder(const int order)
{
    z_order = order;
}
//-----------------------------------------------------------------------------
int AbstractPicture::GetZOrder(void) const
{
    return z_order;
}
//-----------------------------------------------------------------------------
IGraphicElement::Flip AbstractPicture::GetFlip(void) const
{
    return flip;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetFlip(const IGraphicElement::Flip flip)
{
    this->flip = flip;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetAngle(const float _angle)
{
	if(angle < 0.0)
	{
		this->angle = fmod(_angle, 360) + 360;
	}
	else
	{
		this->angle = fmod(_angle, 360);
	}
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetAngle(void) const
{
    return angle;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetScale(const float scale)
{
    x_scale = scale;
    y_scale = scale;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetXScale(const float scale)
{
    x_scale = scale;
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetXScale(void) const
{
    return x_scale;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetYScale(const float scale)
{
    y_scale = scale;
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetYScale(void) const
{
    return y_scale;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetAlpha(const float alpha)
{
    this->alpha = int(alpha) & 255;
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetAlpha(void) const
{
    return float(alpha);
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetXAnchor(const float anchor)
{
    x_anchor = anchor;
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetXAnchor(void) const
{
    return x_anchor;
}
//-----------------------------------------------------------------------------
void AbstractPicture::SetYAnchor(const float anchor)
{
    y_anchor = anchor;
}
//-----------------------------------------------------------------------------
float AbstractPicture::GetYAnchor(void) const
{
    return y_anchor;
}
//-----------------------------------------------------------------------------
